package 测试1;

import java.util.Scanner;

/**
 * Created by hest0 on 2017/7/12.
 */
public class 字符串加密 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            String key = sc.nextLine();
            String data = sc.nextLine();
            System.out.println(encrypt(key, data));
        }
        sc.close();
    }

    //加密过程
    private static String encrypt(String key, String data) {
        String set1 = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
        String set2 = getSet(key);
        System.out.println(set2);
        char[] ch = data.toCharArray();
        for (int i = 0; i < ch.length; i++) {
            String cs = String.valueOf(ch[i]);
            if (set1.contains(cs))
                ch[i] = set2.charAt(set1.indexOf(cs));
        }
        return new String(ch);
    }

    //得到字母表
    private static String getSet(String x) {
        String k = x + "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

        StringBuilder lowSb = new StringBuilder();
        StringBuilder upSb = new StringBuilder();
        for (int i = 0; i < k.length(); i++) {
            String cs = String.valueOf(Character.toUpperCase(k.charAt(i)));
            if (!upSb.toString().contains(cs)) {
                upSb.append(cs);
                lowSb.append(Character.toLowerCase(cs.charAt(0)));
            }
        }

        return lowSb.toString() + upSb.toString();
    }
}
